#!/bin/bash
build_dir="Build"
fd_file="VISIONFIVE2.fd"
if [ -d "$build_dir" ]; then  
    echo "删除目录 $build_dir"  
    rm -rf "$build_dir"    
fi
if [ -f "$fd_file" ]; then  
    echo "删除文件 $fd_file"  
    rm "$fd_file"  
fi
export GCC5_RISCV64_PREFIX="/opt/riscv/bin/riscv64-unknown-elf-" 
export PACKAGES_PATH=$PWD/edk2:$PWD/edk2-platforms 
export EDK_TOOLS_PATH=$PWD/edk2/BaseTools 
export WORKSPACE=$PWD 
cd edk2 
source ./edksetup.sh 
make -C ./BaseTools clean 
make -C ./BaseTools 
make -C ./BaseTools/Source/C 
source ./edksetup.sh BaseTools 
build -a RISCV64 -t GCC5 -p Platform/StarFive/VisionFive2/VisionFive2.dsc 
cp -v $WORKSPACE/Build/VisionFive2/DEBUG_GCC5/FV/VISIONFIVE2.fd ../VISIONFIVE2.fd
cd .. 
echo "EDK2编译完成   生成 $fd_file"
